import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { ManagementForm, ManagementVO, TreeListDTO, TreeListVO } from "@/api/budget/management/types";
import { DeptVO } from "@/api/system/dept/types";
import { BudgetSubjectVO } from "@/api/budget/budgetSubject/types";
import { InheritData } from "@/api/budget/contrastDept/types";

export const listTree = (query?: TreeListDTO): AxiosPromise<TreeListVO[]> => {
  return request({
    url: "/budget/management/listTree",
    method: "post",
    data: query
  });
};


/**
 * 查询管理部门科目设置列表
 * @param query
 * @returns {*}
 */

export const listManagement = (query?: TreeListDTO): AxiosPromise<ManagementVO[]> => {
  return request({
    url: "/budget/management/list",
    method: "post",
    data: query
  });
};


/**
 * 新增管理部门科目设置
 * @param data
 */
export const addManagement = (data: ManagementForm) => {
  return request({
    url: "/budget/management/addManagement",
    method: "post",
    data: data
  });
};

/**
 * 删除管理部门科目设置
 * @param id
 */
export const delManagement = (id: string | number | Array<string | number>) => {
  return request({
    url: "/budget/management/" + id,
    method: "delete"
  });
};
/**
 * 部门列表下拉
 */
export const listManagementDept = (): AxiosPromise<DeptVO[]> => {
  return request({
    url: "/budget/management/listManagementDept",
    method: "get"
  });
};
/**
 * 科目列表下拉
 */
export const getSubjectList = (contrastDate: string): AxiosPromise<BudgetSubjectVO[]> => {
  return request({
    url: "/budget/subject/getSubjectList/" + contrastDate,
    method: "get"
  });
};


/**
 * 继承数据
 * @param data
 */
export const saveInheritData = (data: InheritData) => {
  return request({
    url: "/budget/management/inheritData",
    method: "post",
    data: data
  });

};
